package com.hohd;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;

public class QuotaSerializer_tmp extends JsonSerializer<String> {
    public static final String split_character = "--";
    @Override
    public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException {
        if (StringUtils.isBlank(value)) {
            gen.writeString("");
            return;
        }
        long[] ids;
        String[] idSplit = value.split(split_character);
        int length = idSplit.length;
        ids = new long[length];
        for (int i = 0; i < length; i++) {
            ids[i] = Long.valueOf(idSplit[i]);
        }

        gen.writeArray(ids, 0, length);
    }
}
